import { ClientMessage } from "@runtime/generate/message/ClientMessage";
import { reactive, Ref, ref, UnwrapNestedRefs, WatchStopHandle } from "vue";
export class menuData {
    public Title: string;
    public Key: string;
    public Children: Array<menuData>;
    constructor(title: string = '', key: string = '', children: Array<menuData> = []) {
        this.Title = title
        this.Key = key
        this.Children = children
    }
}

export class TypeData {
    public Asset: string;
    public Content: string;
    public Type: string;
    constructor(Asset: string = '', Content: string = '', Type: string = '') {
        this.Asset = Asset
        this.Content = Content
        this.Type = Type
    }
}

export class Result {
    public Error: string;
    public Message: string;
    public Success: boolean;
    public Result:Array<TypeData> ;
    constructor(typeData: Array<TypeData>, error: string = '', message: string = '', success: boolean) {
        this.Result = typeData
        this.Error = error
        this.Message = message
        this.Success = success
    }
}

export class textData {
    public id: number;
    public title: string;
    public content: string;
    constructor(id: number = 0, title: string = '', content: string = '') {
        this.id = id
        this.title = title
        this.content = content
    }
}

export class modelClass {
    public id: number;
    public name: string;
    public parent: string;
    public asset: string;
    public text: textData;
    constructor(name: string = '', parent: string = '', id: number = 0, asset: string = '', text: textData) {
        this.id = id
        this.name = name
        this.parent = parent
        this.asset = asset
        this.text = text
    }
}

export class Completion {
    public TopicContent: string;//题目内容
    public RightKey: string[];//正确答案
    public AnswerContent: string[];//回答内容
    constructor(topicContent: string = '', rightKey: string[], answerContent: string[]) {
        this.TopicContent = topicContent
        this.RightKey = rightKey
        this.AnswerContent = answerContent
    }
}

export class choiceQuestion {
    public TopicContent: string;//题目内容
    public RightKey: boolean;//正确答案
    public AnswerContent: boolean;//回答内容
    constructor(topicContent: string = '', rightKey: boolean, answerContent: boolean) {
        this.TopicContent = topicContent
        this.RightKey = rightKey
        this.AnswerContent = answerContent
    }
}

export class trainClass {
    public id: number;//ID
    public name: string;//任务名称
    public sort: string;//任务序号
    public types: string;//任务类型
    public SubStatus: boolean;//提交状态
    public asset: string;//模型路径
    public choiceQuestion: choiceQuestion;//判断题类型内容
    public SelectFill: Completion;//选择填空
    constructor(name: string = '', sort: string = '', id: number = 0, types: string = '', SubStatus: false, asset: string = '', choiceQuestion: choiceQuestion, selectFill: Completion) {
        this.id = id
        this.name = name
        this.sort = sort
        this.types = types
        this.SubStatus = SubStatus
        this.asset = asset
        this.choiceQuestion = choiceQuestion
        this.SelectFill = selectFill
    }
}





/**
 * 教学菜单
 */
export default class MenuIndexData {
    private static instance: MenuIndexData = new MenuIndexData();
    /**
     * 教学菜单
     */
    public static get Default(): MenuIndexData {
        return this.instance;
    }

    constructor() {
        window.addEventListener('unload', this.Dispose.bind(this));
    }

    Dispose() {
        window.removeEventListener('unload', this.Dispose);

        for (const watchStopHandle of this.watchStopHandles) {
            watchStopHandle();
        }
        // this.watchStopHandles.clear();
    }
    public LabelDataList: Ref<ClientMessage.LabelLoadResponse['Informations']> = ref([])
    public OptionLabel: Ref<ClientMessage.LabelLoadResponse['Informations']> = ref([])
    public MultimeterData: Ref<menuData> = ref(new menuData)

    private watchStopHandles: Array<WatchStopHandle> = [];

    public async Awake(): Promise<void> {
    }

    public async Destroy(): Promise<void> {
    }
}